#region Using
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using PhotoGallery.Infrastructure.Collections;
#endregion Using

namespace PhotoGallery.Core.Business
{
    public class Operation : Business.BusinessBase<Operation, int>
    {
        #region Fields and Properties

        private String action = String.Empty;
        /// <summary>
        /// 
        /// </summary>
        public String Action
        {
            get { return action; }
            set
            {
                if (value != action)
                {
                    MarkChanged("Action");
                    action = value;
                }
            }
        }

        private String controller = String.Empty;
        /// <summary>
        /// 
        /// </summary>
        public String Controller
        {
            get { return controller; }
            set
            {
                if (value != controller)
                {
                    MarkChanged("Controller");
                    controller = value;
                }
            }
        }

        private String name = String.Empty;
        /// <summary>
        /// 
        /// </summary>
        public String Name
        {
            get { return name; }
            set
            {
                if (value != name)
                {
                    MarkChanged("Name");
                    name = value;
                }
            }
        }

        private DateTime addDate = DateTime.MinValue;
        /// <summary>
        /// 
        /// </summary>
        public DateTime AddDate
        {
            get { return addDate; }
            set
            {
                if (value != addDate)
                {
                    MarkChanged("AddDate");
                    addDate = value;
                }
            }
        }

        private int status = 0;
        /// <summary>
        /// 
        /// </summary>
        public int Status
        {
            get { return status; }
            set
            {
                if (value != status)
                {
                    MarkChanged("Status");
                    status = value;
                }
            }
        }

        #endregion Fields and Properties

        #region Constructors

        public Operation()
        {
        }

        #endregion Constructors

        #region Base overrides

        protected override void ValidationRules()
        {
        }

        protected override Operation DataSelect(int id)
        {
            return Services.DALService.OperationService.Select(id);
        }

        protected override void DataUpdate()
        {
            Services.DALService.OperationService.Update(this);
        }

        protected override void DataInsert()
        {
            Services.DALService.OperationService.Insert(this);
        }

        protected override void DataDelete()
        {
            Services.DALService.OperationService.Delete(this);
        }

        #endregion Base overrides


        public static Operation Find(string controller, string operation)
        {
            return Services.DALService.OperationService.Find(controller, operation);
        }

        public static PagedList<Core.Business.Operation> Search(OperationSearch search)
        {
            return Services.DALService.OperationService.Search(search);
        }

        public static IList<Operation> Find(Role role, int? status)
        {
            return Services.DALService.OperationService.Find(role, status);
        }
    }
}
